<?php

include_once($_SERVER['DOCUMENT_ROOT'] . '/chisholm-swin/application/controllers/ccl_controller.php');

/**
 * Admin Superclass makes sure that the user has sufficient permissions (admin_access) and loads "admin" database permissions
 * @package admin
 */
class admin extends ccl_controller
{
	function __construct()
    {
        // Call the Model constructor
        parent::__construct();
		
		// Redirect if not logged in as admin
		if ( !$this->session->userdata('CurrentUser') || !$this->session->userdata('CurrentUser')->admin_access )
			redirect('authenticate/login');
		
		// Load database with "admin" permissions
		$this->load->database('admin');
		
		// Load sidebar
		$this->data['sidebar'] = $this->load->view('admin/sidebar', $this->data, true);
    }
	
	function index()
	{
		// Load the "default" view
		$this->data['main_content'] = $this->load->view('admin/admin', $this->data, true);
		
		// Load $this->data['main_content'] in the main template
		$this->load->view($this->template, $this->data);
	}
}

?>